import request from '@/utils/request'

// 定义通用API响应类型
interface ApiResponse<T> {
  code: number
  msg: string
  data: T
  count?: number
}

// 律师
interface Lawyer {
  id: number
  lawyer_id: number
  lawyer_name: string
  lawyer_sex: number
  lawyer_mobile: string
  lawyer_tel: string
  lawyer_qq: string
  lawyer_wechat: string
  lawyer_email: string
  lawyer_address: string
  lawyer_prof_flag: number
  lawyer_prof_code: string
  lawyer_prof_img: string
  lawyer_level: number
  lawyer_special: string
  lawyer_resume: string
  lawyer_status: number
  create_time: string
  update_time: string
}

// 律所
interface Lawfirm {
  id: number
  title: string
  province: string
  city: string
  dist: string
  address: string
  phone: string
  email: string
  contact: string
  contact_mobile: string
  remark: string
  create_time: string
  update_time: string
}

// 获取律师列表
export function getLawyerList(params: any): Promise<ApiResponse<Lawyer[]>> {
  return request({
    url: '/api/lawyer/list',
    method: 'get',
    params,
  })
}

// 获取律师详情
export function getLawyerDetail(id: number): Promise<ApiResponse<Lawyer>> {
  return request({
    url: '/api/lawyer/view',
    method: 'get',
    params: { id },
  })
}

// 新增律师
export function addLawyer(data: any) {
  return request({
    url: '/api/lawyer/add',
    method: 'post',
    data,
  })
}

// 编辑律师
export function editLawyer(data: any) {
  return request({
    url: '/api/lawyer/edit',
    method: 'put',
    data,
  })
}

// 删除律师
export function deleteLawyer(id: number) {
  return request({
    url: '/api/lawyer/del',
    method: 'delete',
    data: { id },
  })
}

// 获取律所列表
export function getLawfirmList(params: any): Promise<ApiResponse<Lawfirm[]>> {
  return request({
    url: '/api/lawyer/lawfirm/list',
    method: 'get',
    params,
  })
}

// 获取律所详情
export function getLawfirmDetail(id: number): Promise<ApiResponse<Lawfirm>> {
  return request({
    url: '/api/lawyer/lawfirm/view',
    method: 'get',
    params: { id },
  })
}

// 新增律所
export function addLawfirm(data: any) {
  return request({
    url: '/api/lawyer/lawfirm/add',
    method: 'post',
    data,
  })
}

// 编辑律所
export function editLawfirm(data: any) {
  return request({
    url: '/api/lawyer/lawfirm/edit',
    method: 'put',
    data,
  })
}

// 删除律所
export function deleteLawfirm(id: number) {
  return request({
    url: '/api/lawyer/lawfirm/del',
    method: 'delete',
    data: { id },
  })
}
